package com.jeff.android.lab.architecture.mvp;

import android.os.Handler;
import android.os.Looper;

public class LoginModel implements LoginContract.IModel {

    @Override
    public void login(final Callback callback) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(2000);
                    if (callback != null) {
                        new Handler(Looper.getMainLooper())
                                .post(new Runnable() {
                                    @Override
                                    public void run() {
                                        callback.onSuccess();
                                    }
                                });
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();
    }

    interface Callback {
        void onSuccess();

        void onFail();
    }

}
